<template>
  <el-tree :data="treeData" node-key="id" :render-content="renderNode" />
</template>

<script>
export default {
  data () {
    return {
      treeData: [
        {
          id: 1,
          label: '节点 1',
          children: [
            {
              id: 2,
              label: '子节点 1-1'
            },
            {
              id: 3,
              label: '子节点 1-2',
              children: []
            }
          ]
        },
        {
          id: 4,
          label: '节点 2',
          children: []
        },
        {
          id: 5,
          label: '节点 3'
        }
      ]
    }
  },
  methods: {
    renderNode (h, { node, data }) {
      if (!data.children || data.children.length === 0) {
        return (
          <span>
            <el-checkbox v-model={node.checked} />
            {node.label}
          </span>
        )
      }
      return <span>{node.label}</span>
    }
  }
}
</script>
